package org.advanced.socket;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * @author John.zhang
 * @version Id: Client, v 1.0 2020/12/14 15:32 ZhiYong Exp $
 */
public class Client {

    public static void main(String[] args) throws IOException {
        //socket客户端套接字
        Socket socket = new Socket("localhost", 8081);
        //得到服务段的输出流，进行发送一个数据到服务端
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("Hello World".getBytes(StandardCharsets.UTF_8));
        outputStream.close();
        socket.close();
    }

}
